<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 结合了构造函数继承和原型链继承，没有数据污染，并且能够继承到父类自身的prototype
      //   缺点：执行了两次parent,把父类的属性放在自身构造函数上之后，又把父类的实例对象设为自身的原型对象，重复添加了属性，有性能损失
      function Parent() {
        this.say = function () {
          console.log(this.name);
        };
      }
      Parent.prototype.test = 1;
      function Child() {
        Parent.call(this);
        this.name = "child";
      }
      Child.prototype = new Parent();
      let p = new Child();
      console.log(p);
    </script>
  </body>
</html>
